//
//  CoTTypes.m
//  Tazama NGO
//
//  Created by Day, Patrick B. on 3/6/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "CoTTypes.h"

@implementation CoTTypes

@synthesize coTTypes;

- (id)init
{
    if ((self = [super init]))
	{
        //Do stuff
        
        coTTypes = [[NSMutableArray alloc] init];
        [coTTypes addObject:[self createCotType:@"Rescue Ambulance" unitAbbr:@"RA" cotType:@"a-f-G-E-V-C-E-e-a"]];
        [coTTypes addObject:[self createCotType:@"Battalion Chief" unitAbbr:@"BC" cotType:@"a-f-G-E-V-C-E-f-c-b"]];
        [coTTypes addObject:[self createCotType:@"Engine" unitAbbr:@"E" cotType:@"a-f-G-E-V-C-e-f-e"]];
        [coTTypes addObject:[self createCotType:@"EMS" unitAbbr:@"EM" cotType:@"a-f-G-E-V-C-e-e"]];
        [coTTypes addObject:[self createCotType:@"Truck" unitAbbr:@"T" cotType:@"a-f-G-E-V-C-e-f-t"]];
        [coTTypes addObject:[self createCotType:@"Squad" unitAbbr:@"SQ" cotType:@"a-f-G-E-V-C-e-f-s"]];
        [coTTypes addObject:[self createCotType:@"Command Post" unitAbbr:@"CP" cotType:@"a-f-G-E-V-C-e-f-p"]];
        [coTTypes addObject:[self createCotType:@"Division Chief" unitAbbr:@"DC" cotType:@"a-f-G-E-V-C-e-f-c-d"]];
        [coTTypes addObject:[self createCotType:@"Helicopter" unitAbbr:@"H" cotType:@"a-f-A-C-H-e-f"]];
        [coTTypes addObject:[self createCotType:@"Cycle Team" unitAbbr:@"CT" cotType:@"a-f-G-E-V-C-e-e-b"]];
        [coTTypes addObject:[self createCotType:@"Gator Team" unitAbbr:@"GT" cotType:@"a-f-G-E-V-C-e-e-g"]];
        [coTTypes addObject:[self createCotType:@"Communication Support" unitAbbr:@"CS" cotType:@"a-f-G-E-V-C-e-e-o"]];
        [coTTypes addObject:[self createCotType:@"Rescue Team" unitAbbr:@"REST" cotType:@"a-f-G-U-E-O-B-J-s-r"]];
        [coTTypes addObject:[self createCotType:@"Recon Team" unitAbbr:@"RCNT" cotType:@"a-f-G-U-E-O-B-J-s-n"]];
        [coTTypes addObject:[self createCotType:@"Search Team" unitAbbr:@"SCHT" cotType:@"a-f-G-U-E-O-B-J-s-s"]];
    }
    return self;
}

-(CoTType *)createCotType:(NSString *)unitType unitAbbr:(NSString *)unitAbbr cotType:(NSString *)cotType {
    CoTType *retCot = [[CoTType alloc] init];
    [retCot setUnitType:unitType];
    [retCot setUnitAbbreviation:unitAbbr];
    [retCot setCotType:cotType];
    
    return retCot;
}
-(NSMutableArray *)getAllCoTTypes {
    return coTTypes;
}
-(CoTType *)getCoTTypeByCoTType:(NSString *)type {
    NSEnumerator *enumerator = [coTTypes objectEnumerator];
    id element;
    while (element = [enumerator nextObject]) {
        if ([[element cotType] caseInsensitiveCompare:type] == NSOrderedSame) {
            return element;
        }
    }
    return nil;
}
@end
